var form = layui.form,layer = layui.layer;

//自定义验证规则
form.verify({
    names: function(value){
        if(value.length > 16){
            return '名称限16个字符';
        }
    }
});
var mailbox = xmSelect.render({
    el: '#mailbox',
    data: [
        {name: '张三', value: 1},
        {name: '李四', value: 2},
        {name: '王五', value: 3},
    ]
});
//监听提交
form.on('submit(form-element)', function(data){
    //获取邮件箱多选选中的值
    var selectArr = mailbox.getValue();
    data.field.selectArr = selectArr;
    layer.alert(JSON.stringify(data.field), {
        title: '最终的提交信息'
    });
    setTimeout(function () {
        //保存成功则关闭此页面
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    },1000)
    return false;
});
$("#cancel").on("click",function () {
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
    return false;
});